/**************************************************************
 *   File:	Texture.h
 * Author:	Andrew Thorpe
 *  Brief:	A class to represent and load OpenGL textures
 **************************************************************/
#ifndef _FOSSIL_TEXTURE_H
#define _FOSSIL_TEXTURE_H

#include "TextureManager.h"

namespace Fossil
{
	class Texture
	{
	public:
		static Texture* Create(const char* Filename)
		{
			return TextureManager::Instance()->GetTexture(Filename);
		}

		inline GLuint Handle()	const { return m_Handle; }
		inline GLuint Width()	const { return m_Width; }
		inline GLuint Height()	const { return m_Height; }
		inline GLenum Format()	const { return m_Format; }
	private:
		Texture(void)
			: m_Handle(0)
			, m_Width(0)
			, m_Height(0)
			, m_Format(0) {}
		//Destructor private to ensure we don't delete, texture manager does that when it dies
		//basically it's like hacing a smart pointer, but slightly less
		~Texture(void)
		{
			if(m_Handle)
			{
				glDeleteTextures(1, &m_Handle);
			}
		}

		GLuint	m_Handle;
		GLint	m_Width;
		GLint	m_Height;
		GLint	m_Bpp;
		GLenum	m_Format;

		friend class TextureManager;
	};
}

#endif//_FOSSIL_TEXTURE_H
